//
//  KindCollectionViewCell.m
//  MarianasTrench
//
//  Created by 王晓晨 on 16/3/17.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "KindCollectionViewCell.h"

@interface KindCollectionViewCell ()

@property (nonatomic, strong) UIImageView *picImage;
@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation KindCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubViews];
        
    }return self;
}

- (void)setKindModel:(KindModel *)kindModel {
    if (_kindModel != kindModel) {
        _kindModel = kindModel;
    }
    [self.picImage HANDLEIMAGE(_kindModel.coverPath)];
    self.nameLabel.text = _kindModel.title;
}

- (void)createSubViews {
    self.picImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_picImage];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_nameLabel];
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _picImage.frame = CGRectMake(self.contentView.frame.size.height / 6, self.contentView.frame.size.height / 6, self.contentView.frame.size.height / 3 * 2, self.contentView.frame.size.height / 3 * 2);
    
    _nameLabel.frame = CGRectMake(_picImage.frame.origin.x + _picImage.frame.size.width + self.contentView.frame.size.height / 6, _picImage.frame.origin.y, self.contentView.frame.size.width / 2, _picImage.frame.size.height);
}

@end
